import allure
from selenium.webdriver.common.by import By

from wewrok_app_po.Base.wework_app import WeWorkApp
from wewrok_app_po.Page.add_member_page import AddMemberPage
from wewrok_app_po.Page.search_page import SearchPage


class AddressListPage(WeWorkApp):
    # def __init__(self, driver:WebDriver):
    #     self.driver = driver
    # 点击添加成员按钮，进入添加成员页面
    _ADD_MEMBER = By.XPATH, "//*[@text='添加成员']"
    _SEARCH = By.XPATH, "//*[@resource-id = 'com.tencent.wework:id/l71']/child::*[1]"

    def goto_add_member_page(self):
        # 点击添加成员按钮
        # 滑动直到找到添加成员
        with allure.step("滑动直到找到添加成员,点击通讯录按钮"):
            self.swipe_element(* self._ADD_MEMBER).click()
        # 跳转到添加成员页面

        return AddMemberPage(self.driver)

    def goto_search_page(self):
        with allure.step("点击成员姓名"):
            self.find_and_click(*self._SEARCH)
        return SearchPage(self.driver)
